home *** CD-ROM | disk | FTP | other *** search
- package horst;
-
- import java.awt.Color;
- import java.awt.Component;
- import java.awt.Dimension;
- import java.awt.Graphics;
- import java.awt.Rectangle;
- import java.awt.Shape;
- import java.util.Hashtable;
-
- public class ComponentView extends View {
- protected Component m_comp;
- String m_alt;
-
- public ComponentView(View parent, Element e, HTMLPane container) {
- super(parent, e, container);
- }
-
- protected void drawFocusBox(Graphics g) {
- g.setColor(Color.orange);
-
- for(int i = 0; i <= 3; ++i) {
- g.drawRect(super.m_bounds.x + i, super.m_bounds.y + i, super.m_bounds.width - 2 * i, super.m_bounds.height - 2 * i);
- }
-
- }
-
- protected void flushResources() {
- if (this.m_comp != null) {
- this.m_comp.removeMouseMotionListener(super.m_container);
- this.m_comp = null;
- }
-
- }
-
- protected int getMinimumSpan(int axis) {
- return this.getPreferredSpan(axis);
- }
-
- protected int getPreferredSpan(int axis) {
- if (this.m_comp != null) {
- Dimension size = this.m_comp.getPreferredSize();
- switch (axis) {
- case 0:
- return size.height + super.m_insets.top + super.m_insets.bottom;
- case 1:
- return size.width + super.m_insets.left + super.m_insets.right;
- }
- }
-
- return 0;
- }
-
- protected String getToolTipText() {
- return this.m_alt != null ? this.m_alt : "";
- }
-
- protected void init() {
- Hashtable atts = super.m_elem.getAttributes();
- this.m_alt = (String)super.m_elem.getAttribute("alt");
- this.m_comp = (Component)super.m_elem.getAttribute("component");
- if (this.m_comp != null) {
- this.m_comp.addMouseMotionListener(super.m_container);
- this.m_comp.setVisible(true);
- super.m_container.add(this.m_comp);
- }
-
- }
-
- protected boolean isContainerView() {
- return false;
- }
-
- protected boolean isDisplayableView() {
- return this.m_comp != null;
- }
-
- protected Rectangle layout(int x, int y, int width, LayoutInfo info) {
- super.m_bounds = new Rectangle(x, y, 0, 0);
- if (this.m_comp != null) {
- int compWidth = 0;
- int compHeight = 0;
- int pspan = this.getPreferredSpan(1);
- if (pspan <= width) {
- Dimension sz = this.m_comp.getPreferredSize();
- compWidth = sz.width;
- compHeight = sz.height;
- width = pspan;
- } else {
- Dimension sz = this.m_comp.getPreferredSize();
- compWidth = Math.max(0, width - super.m_insets.left - super.m_insets.right);
- compHeight = sz.height;
- }
-
- Dimension size = this.m_comp.getSize();
- this.m_comp.setBounds(super.m_bounds.x + super.m_insets.left, super.m_bounds.y + super.m_insets.top, compWidth, compHeight);
- super.m_bounds = new Rectangle(x, y, width, compHeight + super.m_insets.top + super.m_insets.bottom);
- }
-
- return super.m_bounds;
- }
-
- protected void move(int x, int y, boolean bMoveFloaters) {
- Rectangle var10000 = super.m_bounds;
- var10000.x += x;
- var10000 = super.m_bounds;
- var10000.y += y;
- if (this.m_comp != null) {
- Dimension size = this.m_comp.getSize();
- this.m_comp.setBounds(super.m_bounds.x + super.m_insets.left, super.m_bounds.y + super.m_insets.top, size.width, size.height);
- }
-
- }
-
- public void paint(Graphics g, Shape alloc) {
- if (this.m_comp != null) {
- this.m_comp.setVisible(super.m_bounds.intersects(alloc.getBounds()));
- }
-
- }
- }
-